/**
 * Project Name:Micro-Services-RPC-Registry
 * File Name   :RegistryServiceClientFactory.java
 * Package Name:com.micro.services.rpc.registry.support
 * Date:2015年9月7日下午11:56:31
 * Copyright (c) 2015, http://my.oschina.net/httpssl All Rights Reserved.
 *
*/

package com.micro.services.rpc.registry.support;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.TreeMap;

import com.micro.services.rpc.registry.ServiceNode;
import com.micro.services.rpc.registry.support.ClientServiceFactory;

/**
 * ClassName:RegistryServiceClientFactory <br/>
 * Function :TODO ADD FUNCTION. <br/>
 * Reason	:TODO ADD REASON. <br/>
 * Date     :2015年9月7日 下午11:56:31 <br/>
 * @author  :http://my.oschina.net/httpssl
 * @email   :491835898@QQ.COM
 * @since   :JDK 1.7
 * @see 	 
 */
public class RegistryServiceClientFactory implements ClientServiceFactory{

	/**
	 * Key 包名.接口名.版本号   => com.mic.service.InterfaceA.0 
	 */
	private TreeMap<String,ServiceNode> CLIENT_SERVICE = new TreeMap<String,ServiceNode>();
	
	@Override
	public Collection<String> getInterfaces() {
		// TODO Auto-generated method stub
		return  Collections.unmodifiableCollection(CLIENT_SERVICE.keySet());
	}
	
	@Override
	public Collection<ServiceNode> getServiceNodes() {
		// TODO Auto-generated method stub
		return Collections.unmodifiableCollection(CLIENT_SERVICE.values());
	}

	@Override
	public List<ServiceNode> pullOnLineService() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean installRegistryServiceNode(ServiceNode serviceNode) {
		CLIENT_SERVICE.put(serviceNode.getNodeName(),serviceNode);
		return true;
	}

	@Override
	public boolean uninstallRegistryServiceNode(ServiceNode serviceNode) {
		// TODO Auto-generated method stub
		CLIENT_SERVICE.remove(serviceNode.getNodeName());
		return true;
	}
	
}